home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / weapons / Plane Strike.lua < prev    next >
Text File  |  2010-08-31  |  4KB  |  98 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Plane Strike + Projectile Plane Strike
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, September 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.planestrike={}
  10. cc.planestrike.planestrike={}
  11.  
  12. -- Load & Prepare Ressources
  13. cc.planestrike.gfx_wpn=loadgfx("weapons/planestrike.png")                -- Weapon Image
  14. setmidhandle(cc.planestrike.gfx_wpn)
  15. cc.planestrike.sfx_plane=loadsfx("airstrike.ogg")
  16.  
  17. --------------------------------------------------------------------------------
  18. -- Weapon: planestrike
  19. --------------------------------------------------------------------------------
  20.  
  21. cc.planestrike.id=addweapon("cc.planestrike","Plane Strike",cc.planestrike.gfx_wpn,0,3)        -- Add Weapon (0 uses, first in round 3)
  22.  
  23. function cc.planestrike.draw()                                            -- Draw
  24.     -- HUD Positioning
  25.     if weapon_shots==0 then
  26.         hudpositioning(pos_invisible)
  27.     end
  28. end
  29.  
  30. function cc.planestrike.attack(attack)                                    -- Attack
  31.     if (weapon_shots<=0) and (weapon_position==1) then
  32.         -- No more weapon switching!
  33.         useweapon(0)
  34.         playsound(cc.planestrike.sfx_plane)
  35.         weapon_shots=weapon_shots+1
  36.         -- Attack
  37.         pid=createprojectile(cc.planestrike.planestrike.id)
  38.         projectiles[pid]={}
  39.         projectiles[pid].x=weapon_x-math.sin(math.rad(135))*getmapheight()*5.0
  40.         projectiles[pid].y=weapon_y+math.cos(math.rad(135))*getmapheight()*5.0
  41.         projectiles[pid].sx=math.sin(math.rad(135))*32.0
  42.         projectiles[pid].sy=-math.cos(math.rad(135))*32.0
  43.         -- End Turn
  44.         endturn()
  45.     end
  46. end
  47.  
  48. --------------------------------------------------------------------------------
  49. -- Projectile: planestrike
  50. --------------------------------------------------------------------------------
  51.  
  52. cc.planestrike.planestrike.id=addprojectile("cc.planestrike.planestrike")    -- Add Projectile
  53.  
  54. function cc.planestrike.planestrike.draw(id)                                -- Draw
  55.     -- Setup draw mode
  56.     setblend(blend_alpha)
  57.     setalpha(1)
  58.     setcolor(255,255,255)
  59.     setscale(1,1)
  60.     setrotation(135)
  61.     -- Draw projectile
  62.     drawimage(cc.planestrike.gfx_wpn,projectiles[id].x,projectiles[id].y)
  63. end
  64.  
  65. function cc.planestrike.planestrike.update(id)                                -- Update
  66.     -- Particle Tail
  67.     particle(p_smoke,projectiles[id].x+math.random(-50,50),projectiles[id].y+math.random(-50,50))
  68.     particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
  69.     particlefadealpha(0.05)
  70.     particle(p_lightpuff,projectiles[id].x+math.random(-50,50),projectiles[id].y+math.random(-50,50))
  71.     particlefadealpha(0.04)
  72.     -- Move (in substep loop for optimal collision precision)
  73.     msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/10)
  74.     msubx=projectiles[id].sx/msubt
  75.     msuby=projectiles[id].sy/msubt
  76.     for i=1,msubt,1 do
  77.         projectiles[id].x=projectiles[id].x+msubx
  78.         projectiles[id].y=projectiles[id].y+msuby
  79.         -- Collision / Water
  80.         if collision(col20x20,projectiles[id].x+projectiles[pid].sx*4,projectiles[id].y+projectiles[pid].sy*4)==1 or (projectiles[id].y)>getwatery()+5 then
  81.             -- Center
  82.             arealdamage(projectiles[id].x,projectiles[id].y,300,250)
  83.             terrainexplosion(projectiles[id].x,projectiles[id].y,200,1)
  84.             -- Front
  85.             arealdamage(projectiles[id].x+projectiles[pid].sx*9,projectiles[id].y+projectiles[pid].sy*9,150,300)
  86.             terrainexplosion(projectiles[id].x+projectiles[pid].sx*9,projectiles[id].y+projectiles[pid].sy*9,200,1)
  87.             -- Fire
  88.             for a=45,360,45 do
  89.                 createobject(o_fire,projectiles[id].x+math.sin(math.rad(a))*250,projectiles[id].y-math.cos(math.rad(a))*250)
  90.             end
  91.             -- Free projectile
  92.             freeprojectile(id)
  93.             break
  94.         end
  95.     end
  96.     -- Scroll to projectile
  97.     scroll(projectiles[id].x+projectiles[pid].sx*9,projectiles[id].y+projectiles[pid].sy*9)
  98. end